package com.tpsix.enums;

import com.tpsix.datascope.AllDataScopeHandler;
import com.tpsix.datascope.CustomDataScopeHandler;
import com.tpsix.datascope.ThisLevelChildrenDataScopeHandler;
import com.tpsix.datascope.ThisLevelDataScopeHandler;
import com.tpsix.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum DataScopeTypeEnum {

    /**
     * 全部
     */
    ALL(1, "全部", StrUtil.toLowerCaseFirstOne(AllDataScopeHandler.class.getSimpleName())),

    /**
     * 本级以及子级
     */
    THIS_LEVEL_CHILDREN(2,"本级以及子级", StrUtil.toLowerCaseFirstOne(ThisLevelChildrenDataScopeHandler.class.getSimpleName())),

    /**
     * 本级
     */
    THIS_LEVEL(3, "本级", StrUtil.toLowerCaseFirstOne(ThisLevelDataScopeHandler.class.getSimpleName())),

    /**
     * 自定义
     */
    CUSTOMIZE(4, "自定义", StrUtil.toLowerCaseFirstOne(CustomDataScopeHandler.class.getSimpleName()));

    private final int type;
    private final String desc;
    private final String handler;

    public static DataScopeTypeEnum of(int type) {
        DataScopeTypeEnum[] values = values();
        for (DataScopeTypeEnum value : values) {
            if (value.type == type) {
                return value;
            }
        }
        return ALL;
    }

}
